package cn.lanqiao.springbootproject.config;

import cn.lanqiao.springbootproject.filter.LoginFilter;
import cn.lanqiao.springbootproject.filter.LoginRedisFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Autowired
    LoginRedisFilter loginRedisFilter;

    //@Bean
    public FilterRegistrationBean registrationBean(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new LoginFilter());
        filterRegistrationBean.addUrlPatterns("/user/*","/role/*","/menu/*");
        filterRegistrationBean.setOrder(10);
//        filterRegistrationBean.setExcludeUrlPatterns("/user/login","/user/register");
        return filterRegistrationBean;
    }

    @Bean
    public FilterRegistrationBean registrationBean1(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(loginRedisFilter);
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(5);
//        filterRegistrationBean.setExcludeUrlPatterns("/user/login","/user/register");
        return filterRegistrationBean;
    }
}
